export default {
	components: {

	},
	data() {
		return {
			inputData: {
				platform_amount:'',
				platform_company:'',
				platform_sn:'',
			},
			waybillDetail:{},
		}
	},
	onLoad(options) {
		var obj;
		// #ifdef APP-PLUS
		var obj = JSON.parse(options.obj);
		// #endif
		
		// #ifdef MP-WEIXIN
		var obj = JSON.parse(decodeURIComponent(options.obj));
		// #endif
		this.waybillDetail = obj;
		 this.inputData.platform_amount = Number(this.waybillDetail.system_line_price) - Number(this.waybillDetail.system_markup_price);
	},
	onShow() {

	},
	methods: {
 
		submitClick() {
			if (this.check.isNull(this.inputData.platform_amount)) {
				uni.showToast({
					title: '请填写分拨运费费用',
					icon:'error'
				});
				return;
			}
			if (Number(this.inputData.platform_amount) > Number(this.waybillDetail.all_order_amount)) {
				uni.showToast({
					title: '运费不能大于等于总运费',
					icon:'error'
				});
				return;
			}
			
			
			if (this.check.isNull(this.inputData.platform_company)) {
				uni.showToast({
					title: '请填写物流公司',
					icon:'error'
				});
				return;
			} 
			uni.showModal({
				title: '确认分拨此运单',
				content: '是否继续操作？',
				confirmText: '确定',
				success: res => {
					if (res.confirm) {
					 this.noPlatFormData();
					}  
				}
			});
		},
		// 	分拨到非平台运单
		noPlatFormData() {
			return ;
			let data = {
				waybill_id: this.waybillDetail.waybill_id,
				platform_amount: this.inputData.platform_amount,
				platform_company: this.inputData.platform_company,
				platform_sn: this.inputData.platform_sn,
			}
			if (this.$refs.loadingCover) this.$refs.loadingCover.show();
			this.http.sendRequest({
				api: this.api.order.allocationNoPlatForm,
				data: data,
				success: res => {
					console.log(res)
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					if (res.code == 1 && res.data) {
						uni.showToast({
							title: '分拨成功'
						})
						uni.navigateBack()
					}
				},
				fail: res => {
					uni.showToast({
						title: res.data
					})
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				}
			});
		},
	}

}